import request from "@/utils/request"

const url = '/pProduct'

// 获取热门商品数据
export function getHotProductAPI() {
    return request({
        url: `${url}/getHot`
    })
}

// 获取商品分页数据
export function getProductPageAPI({ page = 1, pageSize = 10, keyWord = '' }) {
    return request({
        url: `${url}/${page}/${pageSize}`,
        params: {
            keyWord
        }
    })
}

// 获取商品详情
export function getProductDetailAPI(id) {
    return request({
        url: `${url}/getDetail/${id}`
    })
}

// 获取我的商品
export function getMyProductAPI() {
    return request({
        url: `${url}/myProd`
    })
}

// 批量删除商品
export function delProductAPI(id) {
    return request({
        url: `${url}/byId`,
        method: 'DELETE',
        params: {
            id
        }
    })
}

// 添加商品
export function addProductAPI({ title, description, pic, minPrice, maxPrice, skus }) {
    return request({
        url: `${url}/addProd`,
        method: 'POST',
        data: { title, description, pic, minPrice, maxPrice, skus }
    })
}